﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LDCRNewEdit.Services;
using LDCRNewEdit.Model;

namespace LDCRNewEdit.UI.游戏数据
{
    public partial class InputTypeValueForm : Form
    {
        public InputTypeValueForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        public string show(string value, int type)
        {
            this.comboBox1.Items.Add("-1");
            foreach (BaseData data in BaseDataService.BaseDataList[type.ToString()])
            {
                this.comboBox1.Items.Add(data.Name);
            }

            int index = int.Parse(value) + 1;
            if (index > this.comboBox1.Items.Count || index < 0)
            {
                index = 0;
            }

            this.comboBox1.SelectedIndex = index;

            DialogResult result = this.ShowDialog();
            if (result == DialogResult.OK)
            {
                return (this.comboBox1.SelectedIndex - 1).ToString();
            }
            else
            {
                return value;
            }
        }

        private void comboBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            e.Handled = false;
        }
    }
}
